package d0312;
public abstract class Shape {
    public abstract double area();
    public abstract double perimeter();
    public static void main(String[] args) {
        Rectangle rectangle = new Rectangle(1,2);
        System.out.println("矩形的周长：" + rectangle.perimeter());
        System.out.println("矩形的面积：" + rectangle.area());
        Circle circle = new Circle(2);
        System.out.println("圆的周长：" + circle.perimeter());
        System.out.println("圆的面积：" + circle.area());
    }

static class Rectangle extends Shape{
    private int width;
    private int height;
    public Rectangle(int width, int height) {
        this.width = width;
        this.height = height;
    }
    public double area() {
        return width * height;
    }
    public double perimeter() {
        return 2 * (width + height);
    }
}
class Triangle extends Shape{
    private int firstSide;
    private int secondSide;
    private int thirdSide;
    private int height;
    public Triangle(int firstSide, int secondSide, int thirdSide, int height) {
        this.firstSide = firstSide;
        this.secondSide = secondSide;
        this.thirdSide = thirdSide;
        this.height = height;
    }
    public double area() {
        return firstSide + secondSide + thirdSide;
    }
    public double perimeter() {
        return firstSide * height * 1/2;
    }
}
static class Circle extends Shape{
    private int radius;
    public Circle(int radius) {
        this.radius = radius;
    }

    public double area() {
        return 3.14 * this.radius * this.radius;
    }
    public double perimeter() {
        return 2 * 3.14 * this.radius;
    }
}}